package com.tang.sys.controller;

import com.tang.constants.SystemConstants;
import com.tang.sys.ResponseResult;
import com.tang.sys.entity.Comment;
import com.tang.sys.service.ICommentService;
import com.tang.sys.service.ISensitiveWordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 评论表 前端控制器
 * </p>
 *
 * @author shankaka
 * @since 2023-04-14
 */
@RestController
@RequestMapping("/comment")
@Api(tags = "评论",description = "评论相关接口")
public class CommentController {

    @Autowired
    private ICommentService iCommentService;

    @Autowired
    private ISensitiveWordService iSensitiveWordService;

    @GetMapping("/commentList")
    public ResponseResult commentList(Long articleId,Integer pageNum,Integer pageSize){

        return iCommentService.commentList(SystemConstants.ARTICLE_COMMENT,articleId,pageNum,pageSize);
    }


    @PostMapping
    public ResponseResult addComment(@RequestBody Comment comment){

        return iCommentService.addComment(comment);
    }


    @ApiOperation(value = "友链评论列表",notes = "获取一页友链评论")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "页号"),
            @ApiImplicitParam(name = "pageSize",value = "每页大小")
    }
    )
    //友链的评论
    @GetMapping("/linkCommentList")
    public ResponseResult linkCommentList(Integer pageNum,Integer pageSize){

        return iCommentService.commentList(SystemConstants.LINK_COMMENT,null,pageNum,pageSize);
    }
    //动态评论
    @GetMapping("/friendsCommentList")
    public ResponseResult friendCommentList(Integer pageNum,Integer pageSize){

        return iCommentService.commentList(SystemConstants.LINK_COMMENT,null,pageNum,pageSize);
    }


    //获取敏感词的词库
    @GetMapping("/sensitive")
    public ResponseResult sensitive(){

        return iSensitiveWordService.sensitive();
    }
    //删除评论
    @DeleteMapping("{id}")
    public ResponseResult deleteCommentId(@PathVariable("id") Long id){

        return iCommentService.deleteCommentId(id);
    }
}
